package com.baofu.paycore.biz.enums;

import com.baofu.paycore.common.exception.PayCoreBizException;
import com.baofu.paycore.service.facade.enums.PayCoreErrorCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

/**
 * 广义支付命令
 *
 * User: LZQ Date: 2016/04/21  Version: 1.0
 */
@Slf4j
@Getter
@AllArgsConstructor
public enum CommandTypeEnum {

    /**
     * 余额支付
     */
    BALANCE_PAY,

    /**
     * 账户提现
     */
    ACC_WITHDRAW,

    /**
     * 账户冻结
     */
    ACC_FREEZE,

    /**
     * 冻结提现
     */
    UNFREEZE_WITHDRAW,

    /**
     * 解冻转账
     */
    UNFREEZE_TRANSFER,

    /**
     * 银行卡转账
     */
    RECHARGE_TRANSFER,

    /**
     * 银行卡支付
     */
    BANK_PAY,
    /**
     * 银行卡支付确认
     */
    BANK_PAY_CONFIRM,

    /**
     * 余额退款
     */
    BALANCE_REFUND,

    /**
     * 预授权冻结
     */
    PRE_AUTH_FREEZE,

    /**
     * 预授权解冻
     */
    PRE_AUTH_UNFREEZE,

    PRE_AUTH_UNFREEZE_TRANSFER,

    /**
     * 银行卡退款
     */
    BANK_REFUND,
    ;

    public static CommandTypeEnum getCommandType(String key){
        for (CommandTypeEnum commandTypeEnum: values()){
            if(Objects.equals(key,commandTypeEnum.name())){
                return commandTypeEnum;
            }
        }
        log.error("支付指令不支持:{}",key);
        throw new PayCoreBizException(PayCoreErrorCode.UNEXPECTED_ERROR,"支付指令不支持");
    }
    
}
